--- layout: documentation title: Malloy Documentation footer: /generated/footers/visualizations/segment_maps.html ---
The plugin currently supports US maps. Segement maps take as input 4 columns: start latitude , start longitude, end latitude, and end longitude of the segment. The model and data styles for the subsequent examples are:
define airports is (explore 'malloy-data.faa.airports' primary key code airport_count is count(*) ); define flights is (explore 'malloy-data.faa.flights' primary key id2 origin_code renames origin destination_code renames destination origin is join airports on origin_code, destination is join airports on destination_code flight_count is count() routes_map is (reduce origin.latitude origin.longitude latitude2 is destination.latitude longitude2 is destination.longitude flight_count ) );
and data styles are
{ "routes_map": { "renderer": "segment_map" } }
Departing from Chicago
explore flights : [dep_time : @2003-02, origin.code : 'ORD'] | routes_map
explore flights : [dep_time : @2003-02, origin.code : 'ORD'] | reduce routes_map
| routes_map |
|---|
By calling the configured map as a nested query, a trellis is formed.
explore flights : [dep_time : @2003-02, origin.code : 'ORD'] | reduce carrier flight_count routes_map
| carrier | flight_count | routes_map |
|---|---|---|
| UA | 9,443 | |
| AA | 7,255 | |
| MQ | 4,975 | |
| DH | 3,906 | |
| NW | 702 |
explore flights : [dep_time : @2003-02] | reduce : [origin.code : 'ORD'|'SFO'|'JFK'] carrier flight_count ord is routes_map : [ origin.code: 'ORD'] sfo is routes_map : [ origin.code: 'SFO'] jfk is routes_map : [ origin.code: 'JFK']
| carrier | flight_count | ord | sfo | jfk |
|---|---|---|---|---|
| UA | 13,584 | |||
| AA | 9,271 | |||
| MQ | 5,885 | |||
| DH | 4,332 | |||
| OO | 2,338 |